var player;
var dataContent;
console.log('hi~----------1-----------');


function getMedataWithType(type) {

    console.log('2333~----------1-----------type:' + type);

    $.ajax({
        type: 'post',
        // url:'http://localhost:8080/domanshow_springmvc_user_war/role/listmmHtml',
        url: '/proxy/userdemo/role/listmmHtml',
        data: {stringCheck: "", limit: 525, page: 0, type: type},
        dataType: 'json',
        crossDomain: true,
        success: function (data) {
            console.log('hi ok ok ~----------1-----------');
            console.log(data.data.length);

            dataContent = data.data;
            // var obj = JSON.parse(data);


            $('#preloader').delay(1).fadeOut('slow');
            var htmlString = "";
            var contentSuper = "";
            var patchNanme = "";
            var dplayerName = "";
            for (let i = 0; i < data.data.length; i++) {

                var objT = data.data[i];
                htmlString += objT.stringHtml;
                contentSuper += objT.stringPlayHtml;

            }


            $("#chifanmei").html(htmlString);
            $("#nichousha").html(contentSuper);



            if (type == 1){
                $("#typeTitle").html("iOS 目前数量: " +data.data.length );
            }else if (type == 2){
                $("#typeTitle").html("音视频 目前数量: " +data.data.length);
            }else if (type == 3){
                $("#typeTitle").html("java服务器 目前数量: " +data.data.length );
            }
            funcc(data);
        },
        error: function (data) {
            $('#preloader').delay(1).fadeOut('slow');
            console.log('hi NO NO~----------1-----------');
            console.dir(data);
            $("#info").html("服务器发生错误，请与管理员联系");
        }

    });
}




var myArray = new Array();


function closePlay() {

    console.log('dplayer~----------1-----------close ');

    for (let i = 0; i < myArray.length; i++) {

        console.log('cc~---------------------close:' + i);
        var tmpPlay = myArray[i];
        tmpPlay.pause();
    }


}



// name
function funcc(data) {


    console.log('dplayer~----------create-----------coming');
    console.log('数据总个数: ' + data.data.length);

    for (let i = 0; i < data.data.length; i++) {

        var name = "dplayer" + i;
        var item = data.data[i];


        console.log('这个问题的视频个数有 : ' + item.listVideo.length);
        console.log('这个问题的音频个数有 : ' + item.listAudio.length);

        for (let j = 0; j < item.listVideo.length; j++) {

            var listVideoName = name + j;
            var listItem = item.listVideo[j];

            (function () {
                player = new DPlayer({"container": document.getElementById(listVideoName), "video": {"url": listItem.url}});
                window.dplayers || (window.dplayers = []);
                window.dplayers.push(player);
            })();


            let index = myArray.length;
            myArray[index] = player;
        }




        for (let q = 0; q < item.listAudio.length; q++) {

            var listItem = item.listAudio[q];
            var listAudioName = q + name;

            (function () {
                player = new DPlayer({"container": document.getElementById(listAudioName), "video": {"url": listItem.url}});
                window.dplayers || (window.dplayers = []);
                window.dplayers.push(player);
            })();


            let index = myArray.length;
            myArray[index] = player;
        }

    }


};